<template>
  <div>
    <el-card>

      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
<!--        <el-form-item label="订单编号" prop="orderSn">-->
<!--          <el-input-->
<!--            v-model="queryParams.orderSn"-->
<!--            placeholder="请输入订单编号"-->
<!--            clearable-->
<!--            size="small"-->
<!--            @keyup.enter.native="handleQuery"-->
<!--          />-->
<!--        </el-form-item>-->
<!--&lt;!&ndash;        <el-form-item label="下单人" prop="loginName">&ndash;&gt;-->
<!--&lt;!&ndash;          <el-input&ndash;&gt;-->
<!--&lt;!&ndash;            v-model="queryParams.loginName"&ndash;&gt;-->
<!--&lt;!&ndash;            placeholder="请输入下单人"&ndash;&gt;-->
<!--&lt;!&ndash;            clearable&ndash;&gt;-->
<!--&lt;!&ndash;            size="small"&ndash;&gt;-->
<!--&lt;!&ndash;            @keyup.enter.native="handleQuery"&ndash;&gt;-->
<!--&lt;!&ndash;          />&ndash;&gt;-->
<!--&lt;!&ndash;        </el-form-item>&ndash;&gt;-->
<!--        <el-form-item label="收货人姓名" prop="shippingUser">-->
<!--          <el-input-->
<!--            v-model="queryParams.shippingUser"-->
<!--            placeholder="请输入收货人姓名"-->
<!--            clearable-->
<!--            size="small"-->
<!--            @keyup.enter.native="handleQuery"-->
<!--          />-->
<!--        </el-form-item>-->

<!--        <el-form-item label="地址" prop="address">-->
<!--          <el-input-->
<!--            v-model="queryParams.address"-->
<!--            placeholder="请输入地址"-->
<!--            clearable-->
<!--            size="small"-->
<!--            @keyup.enter.native="handleQuery"-->
<!--          />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="支付方式" prop="paymentMethod">-->
<!--          <el-select v-model="queryParams.paymentMethod" placeholder="请选择支付状态" clearable size="small">-->
<!--            <el-option label="支付宝" value="1"/>-->
<!--            <el-option label="微信" value="2"/>-->
<!--            <el-option label="线下" value="3"/>-->
<!--          </el-select>-->

<!--        </el-form-item>-->
<!--        <el-form-item label="订单金额" prop="orderMoney">-->
<!--          <el-input-->
<!--            v-model="queryParams.orderMoney"-->
<!--            placeholder="请输入订单金额"-->
<!--            clearable-->
<!--            size="small"-->
<!--            @keyup.enter.native="handleQuery"-->
<!--          />-->
<!--        </el-form-item>-->






        <el-form-item label="订单状态" prop="orderStatus">
          <el-select v-model="queryParams.orderStatus" placeholder="请选择订单状态" clearable size="small">
              <el-option label="待付款" value="1"/>
              <el-option label="代发货" value="2"/>
              <el-option label="待收货" value="3"/>
              <el-option label="已收货" value="4"/>
              <el-option label="交易取消" value="5"/>
              <el-option label="删除订单" value="6"/>
              <el-option label="取消订单" value="7"/>
              <el-option label="退货" value="8"/>
              <el-option label="换货" value="9"/>
              <el-option label="待审核" value="10"/>
          </el-select>
        </el-form-item>



        <el-form-item>
          <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

    <el-table v-loading="loading" :data="infoList" >
      <el-table-column label="订单编号" align="center" prop="orderSn" />
      <el-table-column label="下单人" align="center" prop="loginName" width="120px"/>..
      <el-table-column label="收货人姓名" align="center" prop="shippingUser" width="85px"/>
      <el-table-column label="地址" align="center" prop="address1" width="230px" />
      <el-table-column label="支付方式" align="center" prop="paymentMethod" >
        <template slot-scope="scope">
          {{scope.row.paymentMethod=='3' ? '支付宝' : scope.row.paymentMethod=='1' ? '微信' : '线下'}}
        </template>
      </el-table-column>
      <el-table-column label="订单金额" align="center" prop="orderMoney" />
      <el-table-column label="优惠金额" align="center" prop="districtMoney" />
      <el-table-column label="运费金额" align="center" prop="shippingMoney" />
      <el-table-column label="支付金额" align="center" prop="paymentMoney" />
<!--      <el-table-column label="发货时间" align="center" prop="address">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.shippingTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="订单状态" align="center" prop="orderStatus" >
        <template slot-scope="scope">
          {{scope.row.orderStatus=='1' ? '代付款' : scope.row.orderStatus=='2' ? '代发货' :
          scope.row.orderStatus=='3' ? '待收货' : scope.row.orderStatus=='4' ? '已收货' :
          scope.row.orderStatus=='5' ? '交易取消' : scope.row.orderStatus=='6' ? '删除订单' :
          scope.row.orderStatus=='7' ? '取消订单' : scope.row.orderStatus=='8' ? '退货' : scope.row.orderStatus=='9' ? '换货' : '待审核'
          }}
        </template>
      </el-table-column>
      <el-table-column label="分类名称" align="center" prop="categoryName" />
      <el-table-column label="商品名称" align="center" prop="productName" />
      <el-table-column label="店铺名称" align="center" prop="shopsName" />
      <el-table-column label="商品类别" align="center" prop="categoryType" >
        <template slot-scope="scope">
          <el-tag
            :type="scope.row.categoryType === '0' ? 'success' : 'warning'"
            disable-transitions>{{scope.row.categoryType ==='0' ? '建房主材类别' : '家居建材类别'}}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.orderStatus=='8'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleChakan(scope.row)"
          >查看退户原因</el-button>
        </template>
      </el-table-column>


    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>


    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>


      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple"> 退货的原因 </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple"> 退货的凭证图片 </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple"> 审核状态 </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple"> 未审核通过原因 </div></el-col>
      </el-row>
      <br/>

      <el-row :gutter="20">
        <el-col :span="6"><div class="grid-content bg-purple"> {{this.orderRetreatReason}} </div></el-col>
        <el-col :span="6"><div class="grid-content bg-purple"> {{this.retreatList.orderRetreatPicture}} </div></el-col>
        <el-col :span="6">
          <div class="grid-content bg-purple">
            <span v-if="this.retreatList.orderRetreatStatus==0">未审核</span>
            <span v-else="this.retreatList.orderRetreatStatus==1">审核通过</span>
            <span v-else="this.retreatList.orderRetreatStatus==2">审核未通过</span>
          </div>
        </el-col>
        <el-col :span="6"><div class="grid-content bg-purple"> {{this.retreatList.orderRetreatFailedReason}} </div></el-col>
      </el-row>

<!--      <el-table v-loading="loading" >-->
<!--        <el-table-column type="selection" width="55" align="center" />-->
<!--        <el-table-column label="退货表的id" align="center" prop="retreatList.orderRetreatId" />-->
<!--        <el-table-column label="订单表的id" align="center" prop="orderId" />-->
<!--        <el-table-column label="退货人的id" align="center" prop="customerId" />-->
<!--        <el-table-column label="退货的原因" align="center" :prop="this.orderRetreatReason" />-->
<!--        <el-table-column label="退货的凭证图片" align="center" prop="orderRetreatPicture" />-->
<!--        <el-table-column label="退货的申请时间" align="center" prop="orderRetreatApplicationTime" width="180">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{retreatList.orderRetreatReason}}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="退货的审核时间" align="center" prop="orderRetreatAuditTime" width="180">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.orderRetreatAuditTime, '{y}-{m}-{d}') }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="0未审核，1审核通过，2审核未通过" align="center" prop="orderRetreatStatus" />-->
<!--        <el-table-column label="审核未通过的原因" align="center" prop="orderRetreatFailedReason" />-->
<!--        <el-table-column label="商家的id" align="center" prop="supplierId" />-->
<!--      </el-table>-->
    </el-dialog>

  </div>
</template>

<script>
import { listppi } from "@/api/shopping/product";
import { findAllListSupe } from "@/api/order/master";
import { getselectById } from "@/api/retreat";

export default {
  data(){
    return{
      orderRetreatReason:'',
      retreatList:Object,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商品图片信息表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderSn: null,
        customerId: null,
        shippingUser: null,
        customerPhone: null,
        province: null,
        city: null,
        district: null,
        address: null,
        paymentMethod: null,
        orderMoney: null,
        districtMoney: null,
        shippingMoney: null,
        paymentMoney: null,
        shippingCompName: null,
        shippingSn: null,
        shippingTime: null,
        payTime: null,
        receiveTime: null,
        orderStatus: null,
        orderPoint: null,
        invoiceTime: null,
        modifiedTime: null,
        supplierId: null
      },
    }
  },


    created() {
      this.getList();

    },
    methods: {

      handleChakan(row){
        getselectById(row.orderId).then(res=>{
          this.open = true;
          this.retreatList = res.data;
          this.orderRetreatReason=this.retreatList.orderRetreatReason
          console.log("****"+JSON.stringify(this.orderRetreatReason))
        })

      },

      getList(){
        this.loading = true;
        findAllListSupe(this.queryParams).then(res=>{
          this.infoList = res.rows;
          this.total = res.total;
          this.loading = false;
        })
      },


      // 表单重置
      reset() {
        this.form = {
          orderId: null,
          orderSn: null,
          customerId: null,
          shippingUser: null,
          province: null,
          city: null,
          district: null,
          address: null,
          paymentMethod: null,
          orderMoney: null,
          districtMoney: null,
          shippingMoney: null,
          paymentMoney: null,
          shippingCompName: null,
          shippingSn: null,
          createTime: null,
          shippingTime: null,
          payTime: null,
          receiveTime: null,
          orderStatus: 0,
          orderPoint: null,
          invoiceTime: null,
          modifiedTime: null,
          categoryName: null,
          productName: null,
          shopsName: null,
          categoryType: null,
          supplierTypeform: null,
          loginName: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },


      }


  }
</script>

<style scoped>

</style>
